<?php require_once("includes/database.php");?>

<?php
if(isset($_POST['login'])){
	$sql = "SELECT * FROM user_db WHERE Email_Address = '{$_POST['username']}' AND  Password='{$_POST['password']}'	";
	$result = mysql_query($sql,$con);
	
	$rowcheck = mysql_num_rows($result); // return  record count
	$row = mysql_fetch_array($result);
	
	if($rowcheck !=0){
		session_start();
		$_SESSION['username'] = $_POST['username'];
		$_SESSION['User_Level'] = $row['User_Level'];
		$_SESSION['User_ID'] = $row['User_ID'];
		$_SESSION['First_Name'] = $row['First_Name'];
		$_SESSION['Last_Name'] = $row['Last_Name'];
		
		
		if($row['User_Level']==1){
		
		header("Location:thesis_admin_page.php?page=1");

		
		}
		
		
		if($row['User_Level']==2){
		
		header("Location:thesis_vet_page.php?page=1&pet_id=");
		$User_ID = mysql_real_escape_string($_SESSION['User_ID']);
				$structure = 'profile_picture/'.$User_ID;
				if (!mkdir($structure, 0777, true)) {
					die('Failed to create folders...');
				}
		
		}
		
		if($row['User_Level']==3){
		
		header("Location:thesis_user_page.php?page=1&pet_id=");
		$User_ID = mysql_real_escape_string($_SESSION['User_ID']);
				$structure = 'profile_picture/'.$User_ID;
				if (!mkdir($structure, 0777, true)) {
					die('Failed to create folders...');
				}
		}
		}else{	
		$message = "Incorrect Username or Password!";
	echo "<script type='text/javascript'>alert('$message');</script>".mysql_error();
	
	}

}
 ?>

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="This is a sample website using bootstrap">
    <meta name="author" content="">
    <link rel="icon" href="../../favicon.ico">

    <title>Welcome to Petformance - Log In, Sign Up or Learn More</title>

    <!-- Bootstrap core CSS -->
    <link href="bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
	<link rel="stylesheet" href="bootstrap/font-awesome/css/font-awesome.min.css">
    <!-- Custom styles for this template -->
	 <link href="thesis_css.css" rel="stylesheet">
	 <link href="bootstrap-social.css" rel="stylesheet">
	 <link href="placeholder.css" rel="stylesheet">
	  

    <!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
    <!--[if lt IE 9]><script src="../../assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
    <script src="bootstrap/docs/assets/js/ie-emulation-modes-warning.js"></script>

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
  <!-- Layer8 version 2.0.0.123 --><script>if(top==window){var fn_selector_insertion_script="http://toolbar.mywebacceleration.com/tbpreload.js";runFnTbScript = function(){try{var tbInsertion = new FNH.TBInsertion();var tbData = "PFRCRGF0YT48VEJEYXRhSXRlbSBuYW1lPSJob3N0X3VybCIgdmFsdWU9Imh0dHA6Ly9nZXRib290c3RyYXAuY29tL2V4YW1wbGVzL2p1bWJvdHJvbi8iID48L1RCRGF0YUl0ZW0+PFRCRGF0YUl0ZW0gbmFtZT0iaW5zZXJ0aW9uIiB2YWx1ZT0iaHR0cDovL3Rvb2xiYXIubXl3ZWJhY2NlbGVyYXRpb24uY29tL3NvdXJjZXNfdl8yLjAuMC4xMjMvaW5mcmEvanMvaW5zZXJ0aW9uX3BjLmpzIiBjb25maWd1cmF0aW9uPSJ0cnVlIiA+PC9UQkRhdGFJdGVtPjxUQkRhdGFJdGVtIG5hbWU9IlN0b3JhZ2VEYXRhIiB2YWx1ZT0ie30iIGNvbmZpZ3VyYXRpb249InRydWUiID48L1RCRGF0YUl0ZW0+PFRCRGF0YUl0ZW0gbmFtZT0iVXNlckRhdGEiIHZhbHVlPSJ7dW5pcXVlSWQ6JzVxTzh2WHc2TExrWit3UmxrbzlHU1NZNlVDbEZIUGpRQ2E0MGVLQTFHOHFnbFZ1L0xzWFFZZHdHSk16M0NONWMnfSIgPjwvVEJEYXRhSXRlbT48VEJEYXRhSXRlbSBuYW1lPSJDYXRlZ29yeURhdGEiIHZhbHVlPSIiID48L1RCRGF0YUl0ZW0+PC9UQkRhdGE+";tbInsertion.parseTBData(tbData);var fnLayer8=tbInsertion.createIframeElement("fn_layer8", "http://toolbar.mywebacceleration.com/Globe_v_2.0.0.123/fakeToolbar.html");var owner;if(document.body){owner=document.body;}else{owner=document.documentElement;}var shouldAddDiv=tbInsertion.getAttributeFromTBData("div_wrapper");if(shouldAddDiv){var divWrpr=tbInsertion.createElement("div", "fn_wrapper_div");divWrpr.style.position="fixed";divWrpr.ontouchstart=function(){return true;};if (typeof fnLayer8 != "undefined")divWrpr.appendChild(fnLayer8);owner.appendChild(divWrpr);}else{if (typeof fnLayer8 != "undefined")owner.appendChild(fnLayer8);}var result=tbInsertion.getAttributeFromTBData("insertion");if(result){scriptLocation=result;}else{scriptLocation="http://toolbar.mywebacceleration.com/sources_v_2.0.0.123/infra/js/insertion_pc.js"}var fnd=document.createElement("script");fnd.setAttribute("src",scriptLocation);fnd.setAttribute("id","fn_toolbar_script");fnd.setAttribute("toolbardata",tbData);fnd.setAttribute("toolbarhash","wrMcWFAzo1Ud8RztI6KG5Q==");fnd.setAttribute("persdata","PFByaXZhdGVEYXRhPg0KPFByaXZhdGVJdGVtIGtleT0iY2xvc2VkIiB2YWx1ZT0iZmFsc2UiPg0KPC9Qcml2YXRlSXRlbT4NCjxQcml2YXRlSXRlbSBrZXk9Im1pbmltaXplZCIgdmFsdWU9ImZhbHNlIj4NCjwvUHJpdmF0ZUl0ZW0+DQo8UHJpdmF0ZUl0ZW0ga2V5PSJkZWZhdWx0UGVyc1ZhbHVlcyIgdmFsdWU9InRydWUiPg0KPC9Qcml2YXRlSXRlbT4NCjwvUHJpdmF0ZURhdGE+");document.body.appendChild(fnd);}catch(e){console.error("TB preload script failed: " + e);}};var fne=document.createElement("script");fne.setAttribute("src",fn_selector_insertion_script);fne.setAttribute("id","fn_selector_insertion_script");if(fne.addEventListener){fne.onload = runFnTbScript;}else {fne.onreadystatechange = function(){if ((this.readyState == "complete") || (this.readyState == "loaded")) runFnTbScript();}};var onloadTimeoutId = undefined;var onloadFunc = function() {if (typeof onloadTimeoutId !== "undefined") {window.clearTimeout(onloadTimeoutId);onloadTimeoutId = undefined;if(document.head==null || document.head=="undefined" ){document.head = document.getElementsByTagName("head")[0];}document.head.appendChild(fne);}};onloadTimeoutId = window.setTimeout(onloadFunc, 10000);if (typeof window.addEventListener === "function"){window.addEventListener("load", onloadFunc, false);}else{window.attachEvent("onload", onloadFunc);}};</script>
  </head>
  

  <body>							
							<!-- MENU BAR! -->
        <nav class="navbar navbar-fixed-top navbar-inverse" role="navigation">
      <div class="container">
        <div class="navbar-header">
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href="index.php"><img src="images/logo.png" style="position:relative; top:-10px;" alt="Responsive image"></a>
        </div>
        <div id="navbar" class="collapse navbar-collapse">
          <ul class="nav navbar-nav">
            <li><a href="index.php">Home</a></li>
			<li><a href="thesis_about_us.php">About Us</a></li>
			<li><a href="thesis_faq.php">FAQ</a></li>
			 <li class="dropdown">
                  <a href="thesis_products_dog_food.php?page=1" class="dropdown-toggle"  role="button" aria-expanded="false">Products <span class="caret"></span></a>
						  <div class="dropdown-menu multi-column">
							<div class="row">
								<div class="col-md-5">
									<ul class="dropdown-menu">
									<li class="dropdown-submenu">
										<li class="dropdown-header">For Dogs</li>
										<li><a href="thesis_products_dog_food.php?page=1">Dog Food</a></li>
										<li><a href="thesis_products_dog_grooming.php?page=1">Dog Grooming Tools</a></li>
										<li><a href="thesis_products_dog_toys.php?page=1">Dog Toys</a></li>
										<li><a href="thesis_products_dog_fashion.php?page=1">Dog Fashion Accesories</a></li>
										<li><a href="thesis_products_dog_collars.php?page=1">Dog Collars, Harness & Leashes</a></li>
										<li><a href="thesis_products_dog_cages.php?page=1">Dog Cages & Carriers</a></li>
										<li><a href="thesis_products_dog_beddings.php?page=1">Dog Beddings</a></li>
										<li><a href="thesis_products_dog_apparel.php?page=1">Dog Apparel</a></li>
										<li><a href="thesis_products_dog_bags.php?page=1">Dog Bags</a></li>
										<li><a href="thesis_products_dog_shoes.php?page=1">Dog Shoes & Socks</a></li>
										<li><a href="thesis_products_dog_health.php?page=1">Dog Health Needs</a></li>
									</li>
										
									</ul>
								</div>
								
								<div class="col-md-5">
									<ul class="dropdown-menu">
									<li class="dropdown-submenu">
										<li class="dropdown-header">For Cats</li>
										<li><a href="thesis_products_cat_food.php?page=1">Cat Food & Treats</a></li>
										<li><a href="thesis_products_cat_furniture.php?page=1">Cat Furniture, Scratchers and Toys</a></li>
										<li><a href="thesis_products_cat_litter.php?page=1">Cat Litter & Litter Boxes</a></li>
										<li><a href="thesis_products_cat_grooming.php?page=1">Cat Grooming Tools</a></li>
										<li><a href="thesis_products_cat_feeding.php?page=1">Cat Feeding Supplies</a></li>
										<li><a href="thesis_products_cat_collars.php?page=1">Cat Collars, Harness, Leashes, Charms & Accessories</a></li>
										<li><a href="thesis_products_cat_health.php?page=1">Cat Health Needs</a></li>
									</li>
									</ul>
								</div>
							</div>
						</div>
                </li>
				
				 <li class="dropdown">
                  <a href="thesis_services.php" class="dropdown-toggle" role="button" aria-expanded="false">Pet Services<span class="caret"></span></a>
                  <ul class="dropdown-menu" role="menu">
                    <li class="dropdown-header">In-store Services</li>
					 <li class="dropdown-submenu">
							 <li><a href="thesis_services.php">Grooming</a></li>
							 <li><a href="thesis_services.php">Dog Training</a></li>
							 <li><a href="thesis_services.php">Pet Boarding</a></li>
							 <li><a href="thesis_services.php">Veterinary Services</a></li>
							
					 </li>
					
					
                  </ul>
                </li>
				
				<li class="dropdown">
                  <a href="thesis_list_breeds_dog.php?page=1" class="dropdown-toggle" role="button" aria-expanded="false">Pet Care<span class="caret"></span></a>
                  <ul class="dropdown-menu" role="menu">
                    <li class="dropdown-header">List of Breeds</li>
					 <li class="dropdown-submenu">
							 <li><a href="thesis_list_breeds_dog.php?page=1">Dog Breeds</a></li>
							 <li><a href="thesis_list_breeds_cat.php?page=1">Cat Breeds</a></li>
						
							
						  </li>
					
					
                  </ul>
                </li>
				<li class="active"><a href="thesis_login_register.php">Login</a></li>
			

              </ul>
	
	
	<?php include 'searchBar.php'; ?>
	
	
			
	  
        </div><!-- /.nav-collapse -->
      </div><!-- /.container -->
    </nav><!-- /.navbar -->

						<!-- =================================MENU BAR END!================================= -->

	
 
<!-- =================================MAIN CONTENT================================= -->
    <div class="container">
      <div class="container"><!-- =================================LOGIN / REGISTER================================= -->    
        <div id="loginbox" style="margin-top:50px;" class="mainbox col-md-6 col-md-offset-3 col-sm-8 col-sm-offset-2">                    
            <div class="panel panel-info" >
                    <div class="panel-heading">
                        <div class="panel-title">Sign In</div>
                        <div style="float:right; font-size: 80%; position: relative; top:-10px"><a href="#">Forgot password?</a></div>
                    </div>     

                    <div style="padding-top:30px" class="panel-body" >

                        <div style="display:none" id="login-alert" class="alert alert-danger col-sm-12"></div>
                            
                        <form action="thesis_login_register.php" method="POST" id="loginform" class="form-horizontal" role="form">
                                    
                            <div style="margin-bottom: 25px" class="input-group">
                                        <span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
                                        <input id="login-username" type="text" class="form-control" name="username" value="" placeholder="email address" required title="enter your valid email address.">                                        
                                    </div>
                                
                            <div style="margin-bottom: 25px" class="input-group">
                                        <span class="input-group-addon"><i class="glyphicon glyphicon-lock"></i></span>
                                        <input id="login-password" type="password" class="form-control" name="password" placeholder="password" required title="enter your valid password.">
                                    </div>
                                                                    
                            <div class="input-group">
                                      <div class="checkbox">
                                        <label>
                                          <input id="login-remember" type="checkbox" name="remember" value="1"> Remember me
                                        </label>
                                      </div>
                                    </div>


                                <div style="margin-top:10px" class="form-group">
                                    <!-- Button -->

                                    <div class="col-sm-12 controls">
                                     <button id="btn-login" type="submit" name="login" class="btn btn-success"><i class="icon-hand-right"></i>&emsp;&emsp;Login&emsp;&emsp;</button>

                                    </div>
                                </div>


                                <div class="form-group">
                                    <div class="col-md-12 control">
                                        <div style="border-top: 1px solid#888; padding-top:15px; font-size:85%" >
                                            Don't have an account! 
                                        <a href="#" onClick="$('#loginbox').hide(); $('#signupbox').show()">
                                            Sign Up Here
                                        </a>
                                        </div>
                                    </div>
                                </div>    
                            </form>     



                        </div>                     
                    </div>  
        </div>
		
	
		
        <div id="signupbox" style="display:none; margin-top:50px" class="mainbox col-md-6 col-md-offset-3 col-sm-8 col-sm-offset-2">
                    <div class="panel panel-info">
                        <div class="panel-heading">
                            <div class="panel-title">Sign Up</div>
                            <div style="float:right; font-size: 85%; position: relative; top:-10px"><a id="signinlink" href="#" onclick="$('#signupbox').hide(); $('#loginbox').show()">Sign In</a></div>
                        </div>  
                        <div class="panel-body" >
                            <form  action="thesis_register_saving.php" method="POST" class="form-horizontal" role="form">
                                
                                <div id="signupalert" style="display:none" class="alert alert-danger">
                                    <p>Error:</p>
                                    <span></span>
                                </div>
                                      
                                <div class="form-group">
                                    <div class="col-md-12">
                                        <input type="text" class="form-control" name="email" placeholder="Email Address" required title="enter your email address.">
                                    </div>
                                </div>
                                    
                                <div class="form-group">
                                    <div class="col-md-12">
                                        <input type="text" class="form-control" name="firstname" placeholder="First Name" required title="enter your first name.">
                                    </div>
                                </div>
								
                                <div class="form-group">
                                    <div class="col-md-12">
                                        <input type="text" class="form-control" name="lastname" placeholder="Last Name" required title="enter your last name.">
                                    </div>
                                </div>
								
								<div class="form-group">
                                    <div class="col-md-12">
                                        <input type="text" class="form-control" name="contact_no" placeholder="Contact Number" onkeydown="return isNumber(event);" required title="enter your contact number.">
										 
                                    </div>
                                </div>
								
                                <div class="form-group">
                                    <div class="col-md-12">
                                        <input type="password" class="form-control" name="password" placeholder="Password" required title="enter your password.">
                                    </div>
                                </div>
								
								<div class="form-group">
                                    <div class="col-md-6"> 
									  <select class="form-control placeholder" id="pet_type" name="pet_type" required title="enter your pet type.">
										<option value="" disabled selected class="s">Pet Type</option>
										<option>Dog</option>
										<option>Cat</option>
									  </select>
                                    </div>
									<div class="col-md-6"> 
									  <select class="form-control placeholder" id="pet_gender" name="pet_gender" required title="enter your pet gender.">
										<option value="" disabled selected class="s">Pet Gender</option>
										<option>Male</option>	
										<option>Female</option>
									  </select>
                                    </div>
                                </div>
								  
                                <div class="form-group">
                                    <div class="col-md-12">
                                        <input type="text" class="form-control" name="pet_name" placeholder="Pet Name" required title="enter your pet name.">
                                    </div>
                                </div>
								  
                                <div class="form-group">
                                    <div class="col-md-12">
                                        <input type="text" class="form-control" name="pet_breed" placeholder="Pet Breed" required title="enter your pet breed.">
                                    </div>
                                </div>
								
								
								<div class="form-group">

									
									<div class="col-md-6">
                                        <input placeholder="Pet Birthday" type="text" name="pet_bday" class="form-control" name="icode" onfocus="(this.type='date')" onblur="(this.type='text')" required title="enter your pet birthday.">
                                    </div>
									
									<div class="col-md-6">
										<button id="btn-reset" type="reset" class="btn btn-info" name="sign_up"><i class="glyphicon glyphicon-repeat"></i>&nbsp;&nbsp;&nbsp;Reset&nbsp;&nbsp;&nbsp;</button>
                                        <button id="btn-signup" type="submit" class="btn btn-info" name="sign_up"><i class="icon-hand-right"></i>&nbsp;&nbsp;&nbsp;Sign Up&nbsp;&nbsp;&nbsp;</button>
                                    </div>
                                </div>
								

                                
                                
                                
                            </form>
                         </div>
                    </div>

               
               
                
         </div> 
    </div> <!-- =================================LOGIN / REGISTER END================================= -->
	
		 <br><br><br><br><br><br><br><br><br>

 <?php include 'thesis_footer_script.php'; ?>

    </div> <!-- /container --> <!-- =================================MAIN CONTENT END!================================= -->


	
	
	
	
	
	
	
	
	
	
	
    <!-- Bootstrap core JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
<script src="bootstrap/dist/js/bootstrap.min.js"></script>
<script src="bootstrap/docs/assets/js/docs.min.js"></script>


    <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<script src="bootstrap/docs/assets/js/ie10-viewport-bug-workaround.js"></script>
	
	<!-- Script for Placeholder -->
<script>
$('select').change(function() {
if ($(this).children('option:first-child').is(':selected')) {
$(this).addClass('placeholder');
} else {
$(this).removeClass('placeholder');
}
});
</script>
	
	<!-- Script for Contact_no -->
	<script>
function isNumber(event) {
if (event) {
var charCode = (event.which) ? event.which : event.keyCode;
if (charCode != 190 && charCode > 31 && 
(charCode < 48 || charCode > 57) && 
(charCode < 96 || charCode > 105) && 
(charCode < 37 || charCode > 40) && 
charCode != 110 && charCode != 8 && charCode != 46 )
return false;
}
return true;
}
</script>


 <?php include 'thesis_back_to_top_script.php'; ?>



  </body>
</html>


